package bo.zhao.action.simple_factory.factory;

import bo.zhao.action.simple_factory.product.ISender;
import bo.zhao.action.simple_factory.product.MailSender;
import bo.zhao.action.simple_factory.product.SMSSender;

public class NormalFactory {

	public ISender produce(String type) {

		ISender sender=null;
		
		if ("mail".equals(type)) {
			//创建对象
			sender = new MailSender();
			//配置对象
			sender.setDelay(9);
			//调用初始化方法
			sender.init();
			sender.prepare();
			return sender;
		} else if ("sms".equals(type)) {
			//创建对象
			sender = new SMSSender();
			//配置对象
			sender.setDelay(21);
			//调用初始化方法
			sender.init();
			sender.prepare();
			return sender;
		} else {
			System.out.println("请输入正确的类型!");
			return null;
		}

	}

}
